home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / t_os / whisper / source / lowio.asm < prev    next >
Encoding:
Assembly Source File  |  1991-10-19  |  1.8 KB  |  134 lines

  1. ;
  2. ; int    creato(char *file, int mode, int attr)
  3. ;            +8         +12       +16
  4.     public    creato
  5. creato    proc    near
  6.     push    ebp
  7.     mov    ebp,esp
  8.     push    ebx
  9.     push    edx
  10.  
  11. reopen:    mov    ah,3Dh        ; open file
  12.     mov    al,[ebp+12]
  13.     mov    edx,[ebp+8]
  14.     int    21h
  15.     jnc    short cre_ok
  16.  
  17.     cmp    ax,02h        ; file not found
  18.     jne    short cre_er
  19.  
  20.     mov    ah,3Ch        ; creat file
  21.     mov    cx,[ebp+16]
  22.     int    21h
  23.     jc    short cre_er
  24.  
  25.     mov    bx,ax
  26.     mov    ah,3Eh        ; close file
  27.     int    21h
  28.     jnc    short reopen
  29.  
  30. cre_er:    mov    errno,ax
  31.     mov    eax,-1
  32.     jmp    short cre_rt
  33.  
  34. cre_ok:    and    eax,0FFFFh
  35. cre_rt:    pop    edx
  36.     pop    ebx
  37.     pop    ebp
  38.     ret
  39. creato    endp
  40.  
  41. ;
  42. ; int    close(int fp)
  43. ;          +8
  44.     public    close
  45. close    proc    near
  46.     push    ebp
  47.     mov    ebp,esp
  48.     push    ebx
  49.  
  50.     mov    ah,3Eh        ; close
  51.     mov    bx,[ebp+8]
  52.     int    21h
  53.  
  54.     jnc    short cl_rt
  55.     mov    eax,-1
  56.     jmp    short cl_er
  57.  
  58. cl_rt:    mov    eax,0
  59. cl_er:    pop    ebx
  60.     pop    ebp
  61.     ret
  62. close    endp
  63.  
  64. ;
  65. ; int    lseek(int fp,long pos,int sk)
  66. ;          +8      +12     +16
  67.     public    lseek
  68. lseek    proc    near
  69.     push    ebp
  70.     mov    ebp,esp
  71.     push    ebx
  72.  
  73.     mov    ah,42h        ; seek
  74.     mov    al,[ebp+16]
  75.     mov    bx,[ebp+8]
  76.     mov    cx,[ebp+14]
  77.     mov    dx,[ebp+12]
  78.     int    21h
  79.  
  80.     jnc    short ls_rt
  81.     mov    eax,-1
  82.     jmp    short ls_er
  83.  
  84. ls_rt:    shl    edx,16
  85.     or    eax,edx
  86. ls_er:    pop    ebx
  87.     pop    ebp
  88.     ret
  89. lseek    endp
  90.  
  91. ;
  92. ; int    read(int fp,void *buf,int sz)
  93. ;         +8      +12      +16
  94.     public    read
  95. read    proc    near
  96.     push    ebp
  97.     mov    ebp,esp
  98.     push    ebx
  99.  
  100.     mov    ah,3Fh        ; read
  101.     mov    bx,[ebp+8]
  102.     mov    edx,[ebp+12]
  103.     mov    cx,[ebp+16]
  104.     int    21h
  105.  
  106.     jnc    short rd_rt
  107.     mov    eax,-1
  108. rd_rt:    pop    ebx
  109.     pop    ebp
  110.     ret
  111. read    endp
  112.  
  113. ;
  114. ; int    write(int fp,void *buf,int sz)
  115. ;          +8      +12      +16
  116.     public    write
  117. write    proc    near
  118.     push    ebp
  119.     mov    ebp,esp
  120.     push    ebx
  121.  
  122.     mov    ah,40h        ; write
  123.     mov    bx,[ebp+8]
  124.     mov    edx,[ebp+12]
  125.     mov    cx,[ebp+16]
  126.     int    21h
  127.  
  128.     jnc    short wt_rt
  129.     mov    eax,-1
  130. wt_rt:    pop    ebx
  131.     pop    ebp
  132.     ret
  133. write    endp
  134.